
<html>
<body>
<?php
    
    function course_availability(){

    $course_selected = $_POST['coursename1'];
   
    $course_available =0;
    //$course_selected = 'scala';
    
    $course_list = file_get_contents('http://en.wikipedia.org/wiki/List_of_programming_languages');
    $course = "|\\b$course_selected\\b|i";
    
    if (preg_match($course,$course_list)){
        echo "course is available";
        $course_available = 1;
    }
    else {
        echo "Invalid course";
        $course_available= 0;
    }
    
        return $course_available;

    }
    $available = course_availability();
    echo $available;
    
?>




</body>
</html>